const db = require('../config/db')

//查询所有员工信息
module.exports.selectemploy = function () {
    let sql = "select * from userinfo"
    return db.base(sql,null)
}

//新建员工信息
module.exports.addemploy = function (data) {
    let sql = "insert into userinfo (avatar,username,password,realname,role) values(?,?,?,?,?)"
    return db.base(sql, data)
}

//删除员工信息
module.exports.deleteemploy = function (data) {
    let sql = "delete from userinfo where id = ?"
    return db.base(sql, data)
}

//修改员工信息
module.exports.updateemploy = function (data) {
    let sql = "update userinfo set avatar = ?, realname = ?, role = ?, password = ? where id = ?"
    return db.base(sql, data)
}

//删除多条员工信息
module.exports.deletemoreemploy = function (data) {
    let ids = data.join(",")  //初始化批量存储Id的字符串格式
    let sql = "delete from userinfo where id in(" + ids + ")"
    return db.base(sql, data)
}